<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'AdminController@login')->name('login');
Route::post('/admin/login','AdminController@postLogin')->name('postLogin');
Route::delete('logout', 'AdminController@destroy')->name('logout');

Route::group(['middleware'=> 'adminAuth'],function(){
    Route::get('admin/users','UserController@index')->name('userList');
    Route::delete('admin/users/{user}','UserController@destroy')->name('deleteUser');
    Route::resource('admin/master','MasterController');
    Route::resource('admin/activity','ActivityController');
    Route::resource('admin/activityOrder', 'ActivityOrderController',[
        'only'=>['index','destroy','edit','update']
    ]);
    Route::resource('admin/sunPicture', 'sunPictureController',[
        'only'=>['index','destroy','edit','update']
    ]);
    Route::resource('admin/postComments','PostCommentController',[
        'only'=>['index','destroy','edit','update']
    ]);
    Route::resource('admin/mvideo','MasterVideoController');
    Route::resource('admin/clubLeader', 'ClubLeaderController', [
        'only' => ['index', 'destroy']
    ]);
    Route::resource('admin/club', 'ClubController', [
        'except' => ['show']
    ]);
    Route::resource('admin/cvideo', 'ClubVideoController', [
        'only' => ['index', 'destroy']
    ]);
    Route::resource('admin/clesson', 'ClubLessonController', [
        'only' => ['index', 'destroy']
    ]);
    Route::resource('admin/ccoach', 'ClubCoachController', [
        'only' => ['index', 'destroy']
    ]);
    Route::resource('admin/questions','QuestionController',[
        'only' => ['index','destroy']
    ]);
    Route::resource('admin/answers','AnswerController',[
        'only' => ['index','destroy']
    ]);
    Route::resource('admin/train', 'TrainController');
    Route::resource('admin/trainOrder', 'TrainOrderController');
    Route::resource('admin/match', 'MatchController');
});

Route::group(['middleware'=>'clubLeaderAuth','prefix' => 'clubLeader','namespace' => 'ClubLeader'],function() {
    Route::resource('','ClubController',['names' => [
        'index' => 'clubLeader',
    ]]);
    Route::resource('/clubInfo', 'ClubController',['name' => [
        'edit' => 'clubInfo.edit'
    ]]);
    Route::resource('/clubVideo', 'ClubVideoController',['names' => [
        'index' => 'clubVideo.index',
        'create' => 'clubVideo.create',
        'edit' => 'clubVideo.edit',
        'store' => 'clubVideo.store',
        'destroy' => 'clubVideo.destroy'
    ]]);
    Route::resource('/clubLesson', 'ClubLessonController',['names' => [
        'index' => 'clubLesson.index',
        'create' => 'clubLesson.create',
        'edit' => 'clubLesson.edit',
        'store' => 'clubLesson.store'
    ]]);
    Route::resource('/clubCoach', 'ClubCoachController',['names' => [
        'index' => 'clubCoach.index',
        'create' => 'clubCoach.create',
        'edit' => 'clubCoach.edit',
        'store' => 'clubCoach.store',
        'destroy' => 'clubCoach.destory'
    ]]);
});

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
    $api->group(['namespace' => 'App\Api\Controller'], function ($api)
    {
        $api->post('user/login','AuthController@authenticate');
        $api->post('user/register','AuthController@register');
        $api->get('user/me','AuthController@AuthenticatedUser');
        $api->group(['middleware' => 'jwt.refresh'],function ($api) {

        });
        $api->post('master/answer', 'MasterController@store');
        $api->get('getallmaster', 'MasterController@index');
        $api->get('masters','MasterController@show');
        $api->get('getmastervideo', 'MasterController@video');
        $api->get('getallmatch','MatchController@index');


        $api->get('getallclub', 'ClubController@index');
        $api->get('clubinfo', 'ClubController@show');
        $api->get('clublesson', 'ClubController@clubLesson');
        $api->get('clubvideo', 'ClubVideoController@show');
        $api->get('getallactivity','ActivityController@index');
        $api->get('getactivity/{id}','ActivityController@show');
        $api->get('activity/addactivityOrder','ActivityOrderController@store');
        //sun picture
        $api->get('sunpicture','SunpictureController@index');
        $api->get('getPost/{id}','SunpictureController@show');

    });
});